#!/usr/bin/env python3
# -*- coding:utf-8 -*-

"""
过滤日志，统计一些东西。
例如统计每秒钟的事务数量等。
"""

import os

flist = os.listdir('/usr1/tpcc_1p1s_nopart/data/pg_log')


gdict = {}

def agg(fname):
    with open(fname, 'r') as f:
        lines = f.readlines()
    
    for line in lines:
        if line.find('Record tra') < 0 or not line.startswith('2023'):
            continue
            
        header = line[0:20]
        if gdict.get(header) is None:
            gdict[header] = 0
        gdict[header] += 1

for fname in flist:
    agg(fname)
    

for k,v in gdict.items():
    print(k, v)


